<!-- 图表列表 -->
<template>
	<view class="Tatal ">
		<view class="renal F" v-for="item in checkList" >
			<view class="renal-text">
				
				<text>{{item.checkTime}}</text>
			</view>
			<!-- 内循环盒子 -->
			<view class="renal1" >
				<!-- 内循环 -->
				<view class="renal2" v-for="ine in item.checkData" >
					<view class="Tet1" >
						<text> {{ine.cheakName}}</text>
					</view>
					<view class="Tet2" >
						<view class="Tet3">
							<text :style="{color:ine.compare!=0?'#FF1515':''}"> {{ine.result}}</text>
							<!-- <text :style="{color:ine.result>ine.value.max&&ine.result<ine.value.min?'#FF1515':''}" >{{ine.result}}</text> -->
						</view>
						<view class="Tet4">
							<image v-if="ine.compare==0" class="img"></image>
							<image v-if="ine.compare==2"  class="img" src="../../static/tab3/tab3top.png"></image>
							<image v-if="ine.compare==1" class="img" src="../../static/tab3/tab3bom.png"></image>
						</view>
					</view>
				</view>
			</view>
			
		</view>
		<text class="loadMore">{{ contentText }}</text>
		
	</view>
	
</template>

<script>
	export default {
		
		data() {
			return {
				name:"",
				pullFlag: true,
				patId:3,
				subId:1,
				checkList:[],
				fetchPageNum:1,
				refreshing: false,
				contentText: '上拉显示更多',
				pageSize: 10
			}
		},
		onLoad(options) {
			var that=this;
			that.patId=options.id;
			that.subId=options.suid;
			that.name=options.suName
			console.log(options)
			
			uni.setNavigationBarTitle({
				title: options.suName
			});
		},
		onShow() {
			this.fetchPageNum = 1;
			this.pullFlag = true;
			this.refreshing = false;
			this.getData();
		},
		onReachBottom() {
			console.log('滑动到页面底部');
			this.contentText = '加载中...';
			if (this.pullFlag) {
				this.fetchPageNum += 1;
				this.pulllists();
			} else {
				this.contentText = '暂无更多数据';
			}
		},
		onPullDownRefresh() {
			uni.startPullDownRefresh({
				//API开始下拉刷新操作
				success: res => {
					console.log('shuacin', this.fetchPageNum);
					this.refreshing = true;
					this.getData(); //下拉刷新重新获取数据
					uni.stopPullDownRefresh(); //API停止下拉刷
				}
			});
		},
		methods: {
			pulllists() {
				console.log(this.fetchPageNum);
				uni.request({
					url:this.$serverUrl + '/app/hospital/patient/checkList',
					data: {
						subjectId:this.subId,
						patientId:this.patId,
						pageNumber: this.fetchPageNum, //当前页数
						pageSize: this.pageSize,
						
					},
					method: 'POST',
					header: {
						token: uni.getStorageSync('token'),
						'content-type': 'application/json',
						'content-type': 'application/x-www-form-urlencoded'
					},
					success: res => {
						console.log(res.data);
						// this.moneymanagerList = res.data.data;
			// uni.setNavigationBarTitle({
			// 	title: JSON.parse(options.suName)
			// });
						if (this.refreshing) {
							uni.showToast({
								title: '已经最新',
								icon: 'none'
							});
							this.refreshing = false;
							uni.stopPullDownRefresh();
							return;
						}
						let lists = [];
						let data = res.data.data;
						for (let i = 0; i < data.length; i++) {
							lists.push(data[i]);
						}
						if (lists.length < this.pageSize) {
							this.pullFlag = false;
						}
						this.pullFlag = false;
					}
				});
			},
			getData(e){
				var that=this
					uni.request({
						url:this.$serverUrl + '/app/hospital/patient/checkList',
						data: {
							subjectId:that.subId,
							patientId:that.patId,
							pageNumber:  1 , //当前页数
							pageSize: this.pageSize
						},
						method:"POST",
						header:{
							'token': uni.getStorageSync('token'),
							'content-type': "application/json",
							'content-type': "application/x-www-form-urlencoded"
						}, 
						success: (res) => {
							
							if (res.data.code == 0) {
								console.log(res.data);
								if (this.refreshing) {
									uni.showToast({
										title: '已经最新',
										icon: 'none'
									});
									this.refreshing = false;
									uni.stopPullDownRefresh();
							
									return;
								}
								let lists = [];
								let data = res.data.data;
								for (let i = 0; i < data.length; i++) {
									lists.push(data[i]);
								}
								if (lists.length < this.pageSize) {
									this.contentText = '暂无更多数据';
								}
								this.lists = res.data.data;
								console.log('得到lists', lists);
								if (this.refreshing) {
									this.refreshing = false;
									uni.stopPullDownRefresh();
									this.checkList = lists;
								} else {
									this.checkList = lists;
									console.info('this.fetchPageNum == ' + this.fetchPageNum);
									// this.fetchPageNum += 1;
									console.log(this.checkList);
								}
							}
							try {
								uni.getStorageSync('data', JSON.stringify(res.data.data.token));
							} catch (e) {}
							
						}
					})
				},
		},
			// 与 methods: { } 同级,不是写在methods里）
		onNavigationBarButtonTap(e) {
					if(e.index==0){
						uni.navigateTo({
							url: '/pages/patientmanage/Renal2?suid='+this.subId+'&patid='+this.patId+'&name='+this.name
							
						})
					}
			 }
	}
</script>

<style>
	page{
		background-color: #F8F8F8;
	}
.renal-text{
	padding-left: 30upx;
	
}
.renal{
	padding-top: 40upx;
	padding-bottom: 40upx;
	/* padding: 40upx 30upx; */
	margin: 0upx 30upx;
	margin-top: 20upx;
	/* height: 270upx; */
	font-size: 30upx;
	color: #848282;
}
/* 内循环 */
.renal1{
	
	padding-top: 35upx;
	flex-wrap: wrap;
	display: flex;
	flex-direction: row;
	justify-content: space-between;
	padding: 30upx 30upx 0upx 30upx;
}

.renal2{
	display: flex;
	margin-bottom: 10upx;
	flex-direction: row;
	height: 50upx;
	width: 260upx;
	justify-content: space-between;
}
.Tet1{
	/* width: 70upx; */
	display: flex;
	flex-direction: row;
}
.Tet2{
	/* width: 200upx; */
	display: flex;
	justify-content: flex-end;
	
}
.Tet3{
	width: 70upx;
	display: flex;
	justify-content: flex-start;
	text-align: left;
}

/* 图标 */
.res{
	/* position: relative; */
	position: absolute;
	bottom:0;
	right:0;
	/* right: 0; */
	margin-bottom: 50upx;
	margin-right: 40upx;
	}
.res-img{
	width: 100upx;
	height: 100upx;
	border-radius:50%;
}
.img{
	height: 16upx;
	width: 16upx;
	margin-left: 30upx;
}

.Text1{
	width: 1000upx;
}

.Text2{
	width: 100upx;
}

.Text3{
	width: 50upx;
}
.loadMore {
	font-size: 30upx;
	color: #555;
	margin-bottom: 20upx;
	margin: 0 auto;
}
</style>
